﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebTestPay.aspx.cs" Inherits="Web.WebTestPay" %>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>倒计时</title>

    <link href="css/cdn.css" rel="stylesheet" />
</head>

<body>
    <div class="se-kl" style="height: 315px;">
        <div class="se-cn">倒计时</div>
        <div class="se-en">COUNT DOWN</div>
        <i class="se-io"></i>
        <div class="se-info">距离结束还剩</div>
        <div class="se-count">
            <div class="se-day"></div>
            <div class="se-hour"><span class="se-txt">00</span></div>
            <div class="se-min"><span class="se-txt">00</span></div>
            <div class="se-sec"><span class="se-txt">00</span></div>
        </div>
        <div style="width: 100%; text-align: center; bottom: 0px; position: absolute;">
            <button type="button" id="sub" style="width: auto; margin: 0 auto; padding: 5px 15px;" onclick="sub()">完成支付</button>
        </div>
    </div>
    <div style="clear: both;"></div>


    <script src="js/jquery.min.js"></script>
    <script src="js/plugins/layer/layer.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var oDate = new Date();
            var nowTime = oDate.getTime(); //现在的毫秒数
            // oDate.setDate(oDate.getDate() + 1); // 设定截止时间为第二天
            var targetDate = new Date("<%=odate%>");
            <%if (Convert.ToDateTime(odate) >= DateTime.Now)%>
             <% {%>
            run(targetDate);

            <% }%>
              <%  else%>
            <%  { %>
       
            $("#sub").attr("disabled","disabled");
             <% }%>


        });

        function run(enddate) {
            getDate(enddate);
            setInterval("getDate('" + enddate + "')", 500);
        }

        function getDate(enddate) {
            var oDate = new Date(); //获取日期对象

            var nowTime = oDate.getTime(); //现在的毫秒数
            var enddate = new Date(enddate);
            var targetTime = enddate.getTime(); // 截止时间的毫秒数
            var second = Math.floor((targetTime - nowTime) / 1000); //截止时间距离现在的秒数

            var day = Math.floor(second / 24 * 60 * 60); //整数部分代表的是天；一天有24*60*60=86400秒 ；
            second = second % 86400; //余数代表剩下的秒数；
            var hour = Math.floor(second / 3600); //整数部分代表小时；
            second %= 3600; //余数代表 剩下的秒数；
            var minute = Math.floor(second / 60);
            second %= 60;
            var spanH = $('.se-txt')[0];
            var spanM = $('.se-txt')[1];
            var spanS = $('.se-txt')[2];

            spanH.innerHTML = tow(hour);
            spanM.innerHTML = tow(minute);
            spanS.innerHTML = tow(second);
        }

        function tow(n) {
            return n >= 0 && n < 10 ? '0' + n : '' + n;
        }

        function sub() {

            $.ajax({
                type: 'post',
                url: '../Hanlder/OrderHandler.ashx?Method=CheckOutOrder',
                data: { cks: "<%=cks%>" },
                success: function (data) {

                    parent.layer.closeAll();
                }
            });

        }
    </script>
</body>


</html>
